<template>
    <el-dialog class="eldialog" :visible.sync="visible" :title="title" :close-on-click-modal="false" append-to-body
        top="2vh" width="98%" :close-on-press-escape="false" :before-close="handleClose">
        <div class="topTable">
            <vxe-table ref="mytable" :height="heightY" :data="articlesData" style="width: 100%; margin-bottom: 10px" border
                stripe highlight-current-row v-loading="loading" :resizable="true">
                <vxe-column type="checkbox" width="60" align="center"></vxe-column>
                <vxe-column field="xingming" title="姓名" width="90" align="center" sortable />
                <vxe-column field="xingbie" title="性别" align="center" width="60">
                </vxe-column>
                <vxe-column field="minzu_mc" title="民族" align="center" width="80" />
                <vxe-column field="zhiwu_jiancheng" title="工作单位及职务" align="left" width="240" />
                <vxe-column field="csny" title="出生年月" width="120" align="center" />
                <vxe-column field="rudangxinxi" title="入党时间" align="center" width="180" />

                <vxe-column field="qrzxl_zg" title="全日制学历" width="160" align="center" />
                <vxe-column field="qrzxlxx_zg" title="毕业院校" width="160" align="center" />
                <vxe-column field="qrzxw_zg" title="全日制学位" width="160" align="center" />
                <vxe-column field="qrzxwxx_zg" title="专业" width="160" align="center" />
                <vxe-column field="zzxl_zg" title="在职学历" width="160" align="center" />
                <vxe-column field="zzxlxx_zg" title="毕业院校" width="160" align="center" />
                <vxe-column field="zzxw_zg" title="在职学位" width="160" align="center" />
                <vxe-column field="zzxwxx_zg" title="专业" width="160" align="center" />

                <vxe-column field="cjgzsj" title="参加工作时间" width="140" align="center" />
                <vxe-column field="zw_sj" title="任现职时间" width="120" align="center" />
                <vxe-column field="zjcc_sj" align="center" title="任现职级时间" width="140" />
            </vxe-table>
            <div class="row" style="background: #fff;">
                <div class="col-sm text-sm-left text-left3 pt-3">
                    <vxe-pager background align="left" :current-page.sync="currentPage" :page-size.sync="perPage"
                        :total="totalItems"
                        :layouts="['PrevJump', 'PrevPage', 'JumpNumber', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total']"
                        @page-change="handleSizeChange">
                    </vxe-pager>
                </div>
            </div>
        </div>
        <rmb-add v-if="showRMB" ref="rmb" @cardreTypeList="init" />
        <div />
    </el-dialog>
</template>
  
<script>
import rmb from '@/views/young/datacollect/rmbInfo/rmb'
import { exportExeclForPerson } from '@/api/young/echarts/cadre/cadre'
import {
    getSzWarningOneTableDetail, getSzWarningTwoTableDetail, getSzWarningThreeTableDetail, getSzWarningFourTableDetail,
    getSzWarningFiveTableDetail, getSzWarningSixTableDetail, getSzWarningTableDetail, getSzWarningTenTableDetail
    , getSzWarningElevenTableDetail, getSzWarningThirteenTableDetail,
    getOrganizationForCountyAndTown, getTwelvPersonGroup
} from '@/api/young/echarts/cadre/cadreNew'
import { getDZPersonByIds, getCountyPersonByIds } from '@/api/young/echarts/cadre/cadre'
export default {
    name: 'statisticsDetail',
    components: {
        'rmb-add': rmb
    },
    data() {
        // eslint-disable-next-line no-return-assign
        return {
            title: '',
            visible: true,
            showPersonOut: false,
            showRMB: false,
            alertPar: '', // 类型
            loading: false,
            searchKeys: ['getintoId', 'roleName'],
            totalItems: 0,
            currentPage: 1,
            perPage: 10,
            cardreList: [],
            articlesData: [],
            heightY: window.innerHeight - 200 + 'px',
            itemList: [], // 权限字段
            paramsList: [], // 条件
            alertPar: '',  // 标题
            downloadAllData: []    // 下载全部的数据
        }
    },
    mounted() {
        //this.init()
    },

    methods: {
        async init(param, alertPar) {
            let resultString = alertPar.split("--")[1]
            this.title = resultString;
            var that = this
            that.totalItems = 0
            that.articlesData = [],
            that.loading = true
            if (that.visible == false) {
                that.currentPage = 1
            }
            that.visible = true
            that.paramsList = param
            that.alertPar = alertPar
            if (param.all != 'true') {
                if (resultString == "政府配备女干部数" || resultString == "党委政府班子兼职的女干部数") {
                    delete param.page
                    delete param.rows
                    var element = document.querySelector('.row');
                    element.style.display = "none";
                }else if(resultString == "配备女干部数（与党委班子不交叉重复计算)" || resultString == "党委政府班子兼职的女干部数") {
                    delete param.page
                    delete param.rows
                    var element = document.querySelector('.row');
                    element.style.display = "none";
                }else {
                    param['page'] = that.currentPage   // 页号
                    param['rows'] = that.perPage   // 条数  
                }
            } else {
                delete param.page
                delete param.rows
            }
            if (that.paramsList.showType == 'one') {
                await getSzWarningOneTableDetail(param).then(function (result) { // 获取单位反查列表数据
                    // eslint-disable-next-line no-empty
                    that.$nextTick(() => {
                        if (result.result) {
                            if (param.all != 'true') {
                                that.totalItems = result.resultdata.count
                                that.articlesData = result.resultdata.data
                            } else {
                                //that.downloadAllData = result.resultdata.data
                                const params = {
                                    'personList': result.resultdata.data,
                                    'fileName': that.alertPar + ' - 人员统计表.xlsx'
                                }
                                exportExeclForPerson(params).then(function (result) {
                                })
                            }
                        }
                        that.loading = false
                    })
                })
            } else if (that.paramsList.showType == 'two') {
                await getSzWarningTwoTableDetail(param).then(function (result) { // 获取单位反查列表数据
                    // eslint-disable-next-line no-empty
                    that.$nextTick(() => {
                        if (result.result) {
                            if (param.all != 'true') {
                                that.totalItems = result.resultdata.count
                                that.articlesData = result.resultdata.data
                            }
                        }
                        that.loading = false
                    })
                })
            } else if (that.paramsList.showType == 'twoTwo') {
                await getSzWarningTwoTableDetail(param).then(function (result) { // 获取单位反查列表数据
                    // eslint-disable-next-line no-empty
                    that.showTypeList = true
                    that.$nextTick(() => {
                        if (result.result) {
                            if (param.all != 'true') {
                                that.totalItems = result.resultdata.count
                                that.articlesData = result.resultdata.data
                            }
                        }
                        that.loading = false
                    })
                })
            } else if (that.paramsList.showType == 'three') {
                await getSzWarningThreeTableDetail(param).then(function (result) { // 获取单位反查列表数据
                    console.log(param, "param");
                    // eslint-disable-next-line no-empty
                    that.showTypeList = true
                    that.$nextTick(() => {
                        if (result.result) {
                            if (param.all != 'true') {
                                that.totalItems = result.resultdata.count
                                that.articlesData = result.resultdata.data
                            }
                        }
                        that.loading = false
                    })
                })
            } else if (that.paramsList.showType == 'seven' || that.paramsList.showType == 'eight'
                || that.paramsList.showType == 'twelve' || that.paramsList.showType == "fourteen" || that.paramsList.showType == 'fifteen'
            ) {
                await getSzWarningTableDetail(that.paramsList).then(function (result) { // 获取单位反查列表数据
                    that.$nextTick(() => {
                        if (result.result) {
                            if (param.all != 'true') {
                                that.totalItems = result.resultdata.count
                                that.articlesData = result.resultdata.data
                            }
                        }
                        that.loading = false
                    })
                })
            } else if (that.paramsList.showType == 'nineCityDz') {
                await getSzWarningTableDetail(that.paramsList).then(function (result) { // 获取单位反查列表数据
                    that.$nextTick(() => {
                        if (result.result) {
                            if (param.all != 'true') {
                                if (resultString == "配备女干部数（与党委班子不交叉重复计算)" || resultString == "党委政府班子兼职的女干部数") {
                                    var element = document.querySelector('.row');
                                    element.style.display = "none";
                                    that.articlesData = result.resultdata.data
                                } else {
                                    that.totalItems = result.resultdata.count
                                    that.articlesData = result.resultdata.data
                                    var element = document.querySelector('.row');
                                    element.style.display = "block";
                                }
                            }
                        }
                        that.loading = false
                    })
                })
            }
            else if (that.paramsList.showType == 'ten') {//第10个表格
                await getSzWarningTenTableDetail(that.paramsList).then(function (result) { // 获取单位反查列表数据
                    that.$nextTick(() => {
                        if (result.result) {
                            if (param.all != 'true') {
                                that.totalItems = result.resultdata.count
                                that.articlesData = result.resultdata.data
                            }
                        }
                        that.loading = false
                    })
                })
            } else if (that.paramsList.showType == 'eleven') {//第11个表格
                await getSzWarningElevenTableDetail(that.paramsList).then(function (result) { // 获取单位反查列表数据
                    that.$nextTick(() => {
                        if (result.result) {
                            if (param.all != 'true') {
                                that.totalItems = result.resultdata.count
                                that.articlesData = result.resultdata.data
                            }
                        }
                        that.loading = false
                    })
                })
            }
            else if (that.paramsList.showType == 'four') {//第4个表格
                await getSzWarningFourTableDetail(that.paramsList).then(function (result) { // 获取单位反查列表数据
                    that.$nextTick(() => {
                        if (result.result) {
                            if (param.all != 'true') {
                                if (resultString == "政府配备女干部数" || resultString == "党委政府班子兼职的女干部数") {
                                    var element = document.querySelector('.row');
                                    element.style.display = "none";
                                    that.articlesData = result.resultdata.data
                                } else {
                                    that.totalItems = result.resultdata.count
                                    that.articlesData = result.resultdata.data
                                    var element = document.querySelector('.row');
                                    element.style.display = "block";
                                }
                            }
                        }
                        that.loading = false
                    })
                })
            } else if (that.paramsList.showType == 'five') {//第5个表格
                await getSzWarningFiveTableDetail(that.paramsList).then(function (result) { // 获取单位反查列表数据
                    that.$nextTick(() => {
                        if (result.result) {
                            if (param.all != 'true') {
                                that.totalItems = result.resultdata.count
                                that.articlesData = result.resultdata.data
                            }
                        }
                        that.loading = false
                    })
                })
            } else if (that.paramsList.showType == 'six') {//第6个表格
                await getSzWarningSixTableDetail(that.paramsList).then(function (result) { // 获取单位反查列表数据
                    that.$nextTick(() => {
                        if (result.result) {
                            if (param.all != 'true') {
                                that.totalItems = result.resultdata.count
                                that.articlesData = result.resultdata.data
                            }
                        }
                        that.loading = false
                    })
                })
            } else if (that.paramsList.showType == 'eightDZ' || that.paramsList.showType == 'fourteenDZ') {
                await getDZPersonByIds(param).then(function (result) { // 获取单位反查列表数据
                    // eslint-disable-next-line no-empty
                    that.$nextTick(() => {
                        if (result.result) {
                            if (param.all != 'true') {
                                that.totalItems = result.resultdata.count
                                that.articlesData = result.resultdata.data
                            }
                        }
                        that.loading = false
                    })
                })
            } else if (that.paramsList.showType == 'tenCounty') {
                await getCountyPersonByIds(param).then(function (result) { // 获取单位反查列表数据
                    that.$nextTick(() => {
                        if (result.result) {
                            if (param.all != 'true') {
                                that.totalItems = result.resultdata.count
                                that.articlesData = result.resultdata.data
                            }
                        }
                        that.loading = false
                    })
                })
            } else if (that.paramsList.showType == 'nineCountyAndTown') {
                await getOrganizationForCountyAndTown(param).then(function (result) { // 获取单位反查列表数据
                    // eslint-disable-next-line no-empty
                    that.$nextTick(() => {
                        if (result.result) {
                            if (param.all != 'true') {
                                that.totalItems = result.resultdata.count
                                that.articlesData = result.resultdata.data
                            }
                        }
                    })
                    that.loading = false
                })
            } else if (that.paramsList.showType == 'thirteen') {
                await getSzWarningThirteenTableDetail(param).then(function (result) { // 获取单位反查列表数据
                    that.showTypeList = true
                    that.$nextTick(() => {
                        if (result.result) {
                            if (param.all != 'true') {
                                that.totalItems = result.resultdata.count
                                that.articlesData = result.resultdata.data
                            }
                        }
                        that.loading = false
                    })
                })
            }
            this.$nextTick(() => {
                this.$refs.mytable.recalculate()
            })
        },
        handleSizeChange({ currentPage, pageSize }) {
            this.currentPage = currentPage
            this.perPage = pageSize
            this.init(this.paramsList, this.alertPar)

        },
        handleClose() {
            this.visible = false;
        }
    }
}
</script>

<style scoped>
.button {
    display: flex;
    justify-content: flex-end;
}

>>>.vxe-header--row {
    background: linear-gradient(180deg, #fff, #ededed) !important;
}
>>>.vxe-table--render-default .vxe-cell{
    white-space: break-spaces;
}
>>>.vxe-cell--label{
    white-space: break-spaces;
}
</style>
  